"""
案例：绘制两条曲线：sin_x = sin(x) cos_x = cos(x/2)/2 [0-8π]
"""
import matplotlib.pyplot as plt
import numpy as np

x = np.arange(0,8 * np.pi+0.1,0.1)
sin_x = np.sin(x)
cos_x = np.cos(x/2)/2

# 画布
plt.figure("Fill_color",facecolor="Lightgray")
# 画面标题
plt.title('fill')
# 画图
plt.plot(x,sin_x,c="red",label="$y=sin(x)$")
plt.plot(x,cos_x,c="blue",label="$y=cos(x)$")

# 填充第一个为横坐标，后面两个没有顺序
plt.fill_between(x,sin_x,cos_x,sin_x>cos_x,color="green")
plt.fill_between(x,sin_x,cos_x,sin_x<cos_x,color="yellow")

# x,y的限制
plt.xlim(0,26)
plt.ylim(-1.5,2)
# x刻度
plt.xticks(range(0,27,2))
# X、Y标题
plt.xlabel("X")
plt.ylabel("Y")

plt.grid(linestyle=":")

plt.legend()
plt.show()